package com.carhailing.coupons.controller;

import com.carhailing.common.domain.coupons.CouponScheduleDto;
import com.carhailing.common.domain.coupons.CouponsAndCouponsSchedule;
import com.carhailing.common.exception.BusinessException;
import com.carhailing.common.result.Result;
import com.carhailing.coupons.service.CouponScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: Gd  优惠券活动场次
 * @package: com.carhailing.coupons.controller
 * @Project: Online_Taxi_Project
 * @Name: CouponScheduleController
 * @Date: 2024-7-25 15:04
 */
@RestController
public class CouponScheduleController {


    @Autowired
    private CouponScheduleService couponScheduleService;

    /**
     * 优惠券活动场次列表
     */
    @PostMapping("couponScheduleList")
    public Result couponScheduleList(@RequestBody CouponScheduleDto couponScheduleDto) {
        List<CouponScheduleDto> couponScheduleDtoList = couponScheduleService.selectCouponScheduleList(couponScheduleDto);
        return Result.success(couponScheduleDtoList);
    }

    /**
     * 查询最近三天需要优惠券场次的场次
     * 优惠券模板信息
     */
//    @PostMapping("couponScheduleListByDateSession")
//    public Result couponScheduleListByDateSession() {
//        CouponsAndCouponsSchedule couponScheduleDtoList = couponScheduleService.couponScheduleListByDateSession();
//        return Result.success(couponScheduleDtoList);
//    }


    /**
     * 查询当前时间可以参与优惠券抢券的优惠券场次、优惠券模板
     */
    @GetMapping(value = "getCurrentSeckillCoupons")
    public Result getCurrentSeckillCoupons() throws InterruptedException {
        // Authorization
        List<CouponsAndCouponsSchedule> list = couponScheduleService.getCurrentSeckillCoupons();
        return Result.success(list);
    }

    /**
     * 获取token令牌
     */
    @GetMapping("getToken")
    public Result getToken(){
        return couponScheduleService.getToken();
    }
}
